<template>
	<view class="page"  :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<c-nav-bar :title="titleHeader" ></c-nav-bar>
		<view class="header">
			<view class="date" @click="calendarShow=!calendarShow">
				<u-icon name="calendar" color='#00BBFC;'></u-icon>
				<span>设置出发日期</span>
				<u-calendar :show="calendarShow"></u-calendar>
			</view>
			<view class="name" @click="nameShow=!nameShow">
				{{name}}
				<u-icon name="edit-pen" color='#00BBFC;'></u-icon>
				<u-popup :show="nameShow" customStyle='{height:"500rpx"}'>
					<view>
						<u--textarea v-model="name" placeholder="请输入游玩名称" autoHeight height='500'></u--textarea>
					</view>
				</u-popup>
			</view>
		</view>
		<view class="content">
			<view class="siedNav">
				<view class="navs">
					<view v-for="(item,index) in navList" :class="navIndex===index?'active':''" :key="index"
						@tap="changeNav(item,index)">
						第{{item}}天
					</view>
				</view>
				<view class="jiayitian" @click="plusDays()">
					<view class="plusNav">
						<span>＋</span>
					</view>
					<span>加一天</span>
				</view>

			</view>
			<view class="items">
				<view class="noAdd" v-if="!travelList.length">
					<image src="https://i.ringzle.com/file/20231025/08a10cf7c97d46f6899de6913dfeb2d1.png"
						mode="aspectFill"></image>
					<view class="text"> 您还未添加景点，去添加吧</view>
					<u-button text="添加景点" type="primary" shape="circle" @click="addport()"></u-button>
				</view>
				<view class="travelList" v-else>
					<view class="" v-for="(item,index) in travelList" :key="index">
						<view class="list">
							<image :src="item.url" mode="aspectFill" style="height: 160rpx;width: 156rpx;">
								
							</image>
							<view class="right">
								<view class="p1">{{item.name}}</view>
								<view class="p2"><text>建议游玩2小时</text></view>
								<view class="p3"><text>开放时间 09:00-21:00</text></view>
							</view>
							<u-icon name="minus-circle" color='#00BBFC;' @click="deleteItem(index)"></u-icon>
						</view>
						<view class="flex" style="display: flex;">
							<view class="bottom">
								<view class="vertical">
								</view>
								<view class="ver-bottom">
								</view>
							</view>
							<view class="text">
								相距5.2km，驾车约15分钟
							</view>
						</view>
					</view>

				</view>
			</view>
		</view>
		<view class="operation" v-if='this.travelList&&this.travelList.length'>
			<u-button @click="handleSubmit()" size="large" text="保存并预览" shape="circle"></u-button>
			<u-button type="primary" size="large" text="继续添加" shape="circle"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'selectShipRoute',
		data() {
			return {
				h:uni.getSystemInfoSync().windowHeight - 87,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				titleHeader:'自定义旅游路线',
				nameValue: '',
				nameShow: false,
				calendarShow: false,
				name: '嵊泗三日游',
				keyword: '',
				navIndex: 5,
				navList: [
					1

				],
				hotShips: [{
						from: '上海',
						to: '嵊泗'
					},
					{
						from: '沈家湾',
						to: '嵊泗'
					}
				],
				ships: [{
						from: '沈家湾',
						to: '嵊泗泗礁'
					},
					{
						from: '沈家湾',
						to: '嵊泗嵊山'
					},
					{
						from: '沈家湾',
						to: '嵊泗枸杞'
					}
				],
				travelList: [],

			}
		},
		onShow: function() {
			this.travelList = this.$store.state.travelList
		},

		methods: {
			addport() {
				uni.navigateTo({
					url: '/pagesTrip/custom-travel/addPort'
				})
			},
			search() {

			},
			clear() {
				this.keyword = "";
			},
			changeNav(item, index) {
				this.navIndex = index;
			},
			selectShip(item) {
				this.getOpenerEventChannel().emit('selectedShip', item);
			},
			plusDays() {
				const length = this.navList.length
				this.navList.push(length + 1)
			},
			deleteItem(row) {
				this.travelList.splice(row, 1)
			},
			handleSubmit() {
				uni.navigateTo({
					url: '/pagesTrip/custom-travel/routeDetail'
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page {
			// padding-top: 130rpx;
		.search {
			background: #fff;
			padding: 17rpx 24rpx 27rpx;


		}

		.header {
			width: 750rpx;
			height: 80rpx;
			border-radius: 0rpx;
			display: flex;
			justify-content: space-between;
			flex-direction: row;
			color: #00BBFC;
			background: #EBF4FF;

			.date,
			.name {
				display: flex;
				flex-direction: row;
				align-items: center;
				margin: 0 15rpx;
			}
		}

		.content {
			border-top: 10rpx solid #F5F5F5;
			display: flex;

			.navs {
				width: 200rpx;
				display: flex;
				flex-direction: column;

				view {
					width: 100%;
					height: 108rpx;
					background: #F5F8FA;
					line-height: 108rpx;
					text-align: center;
					box-shadow: inset 0rpx -2rpx 0rpx 0rpx #EDEDED;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #777777;

					&.active {
						background: #FFFFFF;
						font-family: PingFang-SC-Bold, PingFang-SC;
						font-weight: bold;
						color: #007A69;
					}
				}
			}

			.items {
				width: 750rpx;
				padding: 20rpx;
				background: #F8FAFD;
				height: 100vh;

				.hot {
					&>text {
						font-size: 24rpx;
						font-family: PingFang-SC-Bold, PingFang-SC;
						font-weight: bold;
						color: #111111;
						line-height: 33rpx;
					}

					.h_ships {
						display: flex;
						align-items: center;
						justify-content: space-between;
						flex-wrap: wrap;

						&>view {
							width: calc(50% - 20rpx);
							height: 56rpx;
							background: #F5F8FA;
							border-radius: 4rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							font-size: 24rpx;
							font-family: PingFang-SC-Bold, PingFang-SC;
							font-weight: bold;
							color: #111111;
							margin-top: 21rpx;

							span {
								margin: 0 15rpx;
							}
						}
					}
				}

				.ships {
					&>view {
						text-indent: 17rpx;
						margin-top: 48rpx;
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #111111;
						line-height: 33rpx;
					}
				}
			}
		}
	}

	.plusNav {
		width: 13px;
		height: 13px;
		border-radius: 11px;
		border: #00BBFC solid 0.5px;
		text-align: center;
		color: #00BBFC;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 15rpx;

		text {
			font-size: 26rpx;
			line-height: 26rpx;
			text-align: center;

		}
	}

	.jiayitian {
		color: #00BBFC;
		display: flex;
		width: 80%;
		justify-content: center;
		align-items: center;
		height: 108rpx;
	}

	.noAdd {
		height: 603rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		.text {
			margin-top: 35rpx;
			height: 45rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 400;
			line-height: 0rpx;
			color: rgb(153, 153, 153);
			opacity: 1;
		}

		image {
			width: 45%;
			height: 45%;
			margin-top: 36rpx;
		}
	}

	.list {
		display: flex;
		flex-direction: row;
		width: 750rpx;
		height: 200rpx;
		border-radius: 20rpx;
		background: #FFFFFF;
		align-items: center;

		.u-icon {
			margin-left: 30rpx;
			color: #00BBFC;
		}

		.vertical {}
	}

	.flex {
		.text {
			height: 30rpx;
			font-size: 22rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #888888;
			padding-top: 18rpx;
			padding-left: 6rpx;
		}
	}

	.bottom {

		.vertical {
			border: #CCCCCC solid 1rpx;
			height: 57rpx;
			width: 1rpx;
			transform: translate(3rpx);
		}

		.ver-bottom {
			width: 8rpx;
			height: 8rpx;
			border: #CCCCCC solid 1rpx;
			background: #CCCCCC;
			border-radius: 50%;

		}
	}

	.right {
		margin-left: 26rpx;
		width: fit-content;

		.p1 {
			color: #111111;
			font-size: 32rpx;
		}

		.p2 {
			font-size: 24rpx;

			color: #111111;
			margin: 20rpx 0 22rpx;

			text:nth-child(2) {
				display: inline-block;
				margin: 0 15rpx;
				font-size: 20rpx;
				color: #EFEFEF;
			}
		}

		.p3 {
			text {
				display: inline-block;
				padding: 6rpx;
				font-size: 22rpx;
				color: #999999;
				margin-bottom: 18rpx;
				border-radius: 4rpx;
			}
		}

		.p4 {
			font-size: 22rpx;
			color: #AAAAAA;

			text {
				font-size: 38rpx;
				color: #FF4141;
				margin-right: 4rpx;
			}
		}
	}

	.operation {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 30rpx;
		background-color: #fff;
		height: 180rpx;
		position: fixed;
		bottom: 0;
		width: 100%;
		z-index: 10;
		box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.06);


		.u-button--large {
			height: 88rpx;
			width: 300rpx;

		}

	}
</style>